﻿using System;
using System.Collections.Generic;
using System.Text;
using ToDoList.Entity.Models;
using System.Linq;

namespace NewToDoList.logic
{
    
    public class OperateUser
    {

        private static todoContext _ctx = new todoContext();
        public void SignUp(string password, string nickName)
        {
            Users user = new Users
            {
                UserName = nickName,
                Password = password
            };
            _ctx.Users.Add(user);
            _ctx.SaveChanges();

        }

        public bool SignIn(int id, string password)
        {
            var user = _ctx.Users.SingleOrDefault(a => a.UserId == id && a.Password.Equals(password));
            if (user != null)
            {
                return true;
            }
            else
                return false;
        }
    }
}
